# -*- coding = utf-8 -*-
from sentence_transformers import SentenceTransformer, util
import json

data_name = 'kaggle_long'
model_save_path = './model_hub/resultModel_' + data_name
model = SentenceTransformer(model_save_path)


def calculate(s1, s2):
    if s1 and s2:
        embedding1 = model.encode(s1, convert_to_tensor=True)
        embedding2 = model.encode(s2, convert_to_tensor=True)
        similarity = util.cos_sim(embedding1, embedding2).item()
        return round(similarity, 5)


def single_test():
    sentence1 = 'The UK Labour members of the PES Group welcome the adoption of their contribution to the ongoing ' \
                'work of the IGC on reinforced cooperation  without endorsing every single detail. '
    sentence2 = 'British Labour members of the Group of the Party of European Socialists welcome the welcomed ' \
                'contribution to the continuous work of the IGC on closer cooperation  without fully adhere to all ' \
                'the details of it. '
    print(calculate(sentence1, sentence2))


if __name__ == '__main__':
    # read_json()
    single_test()
